<template>
  <div id="rose-chart">
    <div class="rose-chart-title">分厂能源分布</div>
    <dv-conical-column-chart :config="config" style="width:400px;height:300px;margin-left: 15px;margin-top: 25px" />
  </div>
</template>

<script>
export default {
  name: 'RoseChart',
  data () {
    return {
      config: {}
    }
  },
  methods: {
    createData () {
      const { randomExtend } = this

      this.config = {
        data: [
          {
            name: '动力',
            value: randomExtend(30, 150)
          },
          {
            name: '化工',
            value: randomExtend(30, 150)
          },
          {
            name: '供电',
            value: randomExtend(30, 150)
          },
          {
            name: '气体',
            value: randomExtend(30, 150)
          },
          {
            name: '污水',
            value: randomExtend(30, 150)
          },
          {
            name: '液化',
            value: randomExtend(30, 150)
          },
          {
            name: '运输',
            value: randomExtend(30, 150)
          }
        ],
        showValue: true,
        img: [
          require('./img/1st.png'),
          require('./img/2st.png'),
          require('./img/3st.png'),
          require('./img/4st.png'),
          require('./img/5st.png'),
          require('./img/6st.png'),
          require('./img/7st.png')
        ]
      }
    },
    randomExtend (minNum, maxNum) {
      if (arguments.length === 1) {
        return parseInt(Math.random() * minNum + 1, 10)
      } else {
        return parseInt(Math.random() * (maxNum - minNum + 1) + minNum, 10)
      }
    }
  },
  mounted () {
    const { createData } = this

    createData()

    setInterval(createData, 3000)
  }
}
</script>

<style lang="less">
#rose-chart {
  width: 30%;
  height: 100%;
  background-color: rgba(6, 30, 93, 0.5);
  border-top: 2px solid rgba(1, 153, 209, .5);
  box-sizing: border-box;

  .rose-chart-title {
    height: 50px;
    font-weight: bold;
    text-indent: 20px;
    font-size: 20px;
    display: flex;
    align-items: center;
  }

  .dv-charts-container {
    height: calc(~"100% - 50px");
  }
}
</style>
